package stack;

import java.util.*;

/**
 * @author dx
 * @version 1.0
 * @date 2022/3/30 9:35
 * @description:  力扣 1441  用栈操作构建数组
 */
public class BuildArray {
    public List<String> buildArray(int[] target,int n){
       Set<Integer> set = new HashSet<Integer>();
       for(int nums :target) {
           set.add(nums);

       }
        List<String> list = new ArrayList<String>();
       int len  = Math.min(n,target[target.length-1]);
       for(int i =1;i<n;i++){
           if(set.contains(i)){
               list.add("push");
           }else{
               list.add("push");
               list.add("pop");
           }
       }
       return list;
    }
}
